package cn.silver.module.authority.bean;

import cn.silver.framework.excel.annotation.ExcelDictFormat;
import cn.silver.framework.excel.convert.ExcelDictConvert;
import cn.silver.framework.mybatis.bean.BusBean;
import cn.silver.module.system.models.RoleModel;
import cn.silver.module.authority.domain.SysRole;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

/**
 * 角色信息视图对象 sys_role
 *
 * @author Silver Zhou
 */
@Data
@NoArgsConstructor
@ExcelIgnoreUnannotated
@AutoMappers({
        @AutoMapper(target = SysRole.class),
        @AutoMapper(target = RoleModel.class, reverseConvertGenerate = false)
})
@EqualsAndHashCode(callSuper = true)
@Schema(name = "RoleBean", title = "角色信息对象")
public class RoleBean extends BusBean implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(title = "角色类型")
    @ExcelDictFormat(dictType = "role_type")
    @ExcelProperty(value = "角色类型", converter = ExcelDictConvert.class)
    private String type;

    /**
     * 数据范围（1：全部数据权限 2：自定数据权限 3：本部门数据权限 4：本部门及以下数据权限）
     */
    @Schema(title = "数据范围")
    @ExcelDictFormat(dictType = "role_scope")
    @ExcelProperty(value = "数据范围", converter = ExcelDictConvert.class)
    private String scope;

    /**
     * 角色状态（0正常 1停用）
     */
    @Schema(title = "角色状态")
    @ExcelDictFormat(dictType = "role_status")
    @ExcelProperty(value = "角色状态", converter = ExcelDictConvert.class)
    private String status;

    @Schema(title = "是否初始化角色")
    private Boolean built;
    /**
     * 显示顺序
     */
    @Schema(title = "角色排序")
    @ExcelProperty(value = "角色排序")
    private Integer sort;

    /**
     * 用户是否存在此角色标识 默认不存在
     */
    @Schema(title = "用户是否存在此角色标识")
    private boolean flag = false;
    @Schema(title = "授权范围")
    private List<String> deptIds;
    @Schema(title = "访问权限范围")
    private List<String> menuIds;

    public RoleBean(String roleId) {
        this.setId(roleId);
    }
}
